[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
ctrlbrk() Set Control-Break Handler
#include <dos.h>
void ctrlbrk(fptr);
int (*fptr)(void); Handler function
ctrlbrk() modifies interrupt vector 0x23 to call a new control-break
handler function pointed to by 'fptr'. Rather than call the new
handler function directly, ctrlbrk() establishes a DOS interrupt
handler that calls the function.
The new handler function can carry out whatever valid operations and
system calls it requires, and can use longjmp() to return to any
desired point in the program.
Returns: Nothing. 0 is returned by the handler function to
abort the current program; any different value causes
the program to resume execution.
Portability: MS-DOS only.
-------------------------------- Example ---------------------------------
The following statements install a control break handler which will
only allow the program to be interrupted at a given time.
#include <stdio.h> /* for printf */
#include <dos.h> /* for ctrlbrk */
int ok2break = 1;
int brk_handler(void)
{
if (ok2break) {
printf("Aborting program\n");
return(0);
}
else {
printf("Unable to abort at this time\n");
return(1);
}
}
main()
{
ctrlbrk(brk_handler);
ok2break = 0;
/* do some file operations which can't be interrupted */
ok2break = 1;
/* do some operations which can be interrupted */
}
See Also:
longjmp()
setjmp()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson